package com.github.tangmonkmeat;

/**
 * Description:
 *
 * @author zwl
 * @version 1.0
 * @date 2021/5/9 上午11:21
 */
public class 下标对中的最大距离 {

    public static void main(String[] args) {

        double l = Math.pow(10.0,9.0);

        System.out.println(new 下标对中的最大距离().maxDistance(new int[]{30,29,19,5},new int[]{25,25,25,25,25}));

    }

    public int maxDistance(int[] nums1, int[] nums2) {
        int max = 0;
        int end = 0;
        for (int i = 0; i < nums1.length; i++) {
            int j = end;
            for (; j < nums2.length; j++) {
                if (nums1[i] > nums2[j]){
                    end = j;
                    break;
                }
            }
            max = Math.max(j - i - 1,max);
        }
        return max;
    }
}
